package com.atguigu.jxc.controller;

import com.atguigu.jxc.domain.ServiceVO;
import com.atguigu.jxc.entity.DamageList;
import com.atguigu.jxc.service.DamageService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;
import java.util.Map;

/**
 * ClassName: DamageController
 * Package: com.atguigu.jxc.controller
 *
 * @Description:
 * @Author: xvyy
 * @Create: 2025/2/21 - 21:53
 * @Version: v1.0
 */
@RestController
@RequestMapping("/damageListGoods")
public class DamageController {

    @Autowired
    private DamageService damageService;

    /**
     * 保存报损单信息
     * @param damageList 报损单信息
     * @param damageListGoodsStr 报损单商品信息字符串
     * @param session 会话信息
     * @return ServiceVO 报损单保存结果
     */
    @PostMapping("/save")
    @RequiresPermissions(value = {"商品报损", "库存管理"})
    public ServiceVO save(DamageList damageList, String damageListGoodsStr, HttpSession session) {
        return damageService.save(damageList, damageListGoodsStr, session);
    }

    /**
     * 根据时间查询报损单列表
     * @param sTime 开始时间
     * @param eTime 结束时间
     * @return Map<String, Object> 报损单列表
     */
    @PostMapping("/list")
    @RequiresPermissions(value = {"商品报损", "库存管理"})
    public Map<String, Object> list(String sTime, String eTime) {
        return damageService.list(sTime, eTime);
    }

    /**
     * 根据报损单报损单id查询报损单详情
     * @param damageListId 报损单id
     * @return Map<String, Object> 报损单详情
     */
    @PostMapping("/goodsList")
    @RequiresPermissions(value = {"商品报损", "库存管理"})
    public Map<String, Object> goodsList(Integer damageListId) {
        return damageService.goodsList(damageListId);
    }



}
